package myMapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import myClass.product;
import myClass.product_img;

public interface productMapper {

//获取指定类别的所有商品
	@Select("SELECT * FROM tb_product WHERE kind=#{kind} AND status!=-1")
	public List<product> selectProductInfoByKind(@Param("kind") String kind);
//获取指定id的商品
	@Select("SELECT * FROM tb_product WHERE product_id=#{product_id}")
	public List<product> selectProductByID(@Param("product_id") int product_id);
//获取商品对应的图片
	@Select("SELECT * FROM tb_product_img WHERE product_id=#{product_id}")
	public List<product_img> selectProductImgById(@Param("product_id")int product_id);
//更新商品售出数量与库存
	@Update("UPDATE tb_product SET sold+=#{num},storage-=#{num} WHERE product_id=#{product_id}")
	public void updateProductSoldStorage(@Param("product_id")int product_id,@Param("num")int num);

	
}
